<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <el-table
        :data="rightsList"
        border
        stripe
        style="width: 100%">
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column prop="level" label="权限等级">
          <template slot-scope="scoped">
            <el-tag :type="levelColor[scoped.row.level]">{{ levelInfo[scoped.row.level] }}</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'Rights',
  data () {
    return {
      rightsList: [],
      levelInfo: {
        0: '一级',
        1: '二级',
        2: '三级'
      },
      levelColor: {
        0: 'primary',
        1: 'success',
        2: 'warning'
      }
    }
  },
  methods: {
    async getRightsList () {
      const { data: res } = await this.$http.get('rights/list')
      if (res.meta.status === 200) this.rightsList = res.data
    }
  },
  created () {
    // 加载所有权限列表
    this.getRightsList()
  }
}
</script>

<style scoped>

</style>
